{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "The weapon is on the player"

// By ArtemQa146

//________________$$$$
//______________$$____$$
//______________$$____$$
//______________$$____$$
//______________$$____$$
//______________$$____$$
//__________$$$$$$____$$$$$$
//________$$____$$____$$____$$$$
//________$$____$$____$$____$$__$$
//_$$$$$__$$____$$____$$____$$____$$
//_$____$$$$________________$$____$$
//_$______$$______________________$$
//__$$____$$______________________$$
//___$$___$$___By ArtemQa146______$$
//____$$__________________________$$
//_____$$$________________________$$
//______$$______________________$$$
//_______$$$____________________$$
//________$$____________________$$
//_________$$$________________$$$
//__________$$________________$$
//__________$$$$$$$$$$$$$$$$$$$$


const
    //  
    Colt45 = 1@
    Silenced = 2@
    Deagle = 3@
    Sawnoff = 4@
    Micro_uzi = 5@
    Tec9 = 6@
    Chromegun = 7@
    Shotgun = 8@
    Mp5 = 9@
    ak47 = 10@
    m4 = 11@
    cuntgun = 12@
    sniper = 13@
    Parachute = 14@
    Knuckles = 15@
    Knuckles_2 = 16@
    N_Goggles = 17@
    T_Goggles = 18@
    
    //  
    Pistol = 30@
    Rifle = 31@
    Weapon_id_pistol = 29@
    Weapon_id_rifle = 28@
    Bit_Sets = 27@
    Only_Priority_Rifle = 26@
    Only_Priority_Pistol = 25@
    Ammo_check = 24@
    
    // 
    Rifle_Priority = 1
    Shotguns_Priority = 2
    Sniper_Priority = 3
    Pistols_Priority = 4
    Uzi_Priority = 5
    Sawnoff_Priority = 6
    Back_visible = 7
    Left_visible = 8
    Parachute_Priority = 9
    Knuckles_Visible = 10
    Knuckles_Double = 11
    Knuckles_Double_Visible = 12
    Only_Priority_Visible = 13
    Goggles = 14
    
    //  
    Pistol_X = 0.1
    Pistol_Y = 0.0
    Pistol_Z = -0.065
    
    Rifle_X = 0.27
    Rifle_Y = -0.13
    Rifle_Z = 0.0
    
    Rara_X = 0.10
    Rara_Y = -0.15
    Rara_Z = 0.0
end

//   : 19@, 20@, 21@, 22@, 23@.
//  : 0@

08C3: clear Bit_Sets bit Rifle_Priority
08C3: clear Bit_Sets bit Shotguns_Priority
08C3: clear Bit_Sets bit Sniper_Priority
08C3: clear Bit_Sets bit Pistols_Priority
08C3: clear Bit_Sets bit Uzi_Priority
08C3: clear Bit_Sets bit Sawnoff_Priority
08C3: clear Bit_Sets bit Parachute_Priority
08C3: clear Bit_Sets bit Knuckles_Visible
08C3: clear Bit_Sets bit Knuckles_Double
08C3: clear Bit_Sets bit Knuckles_Double_Visible
08C3: clear Bit_Sets bit Goggles

08C3: clear Bit_Sets bit Back_visible
08C3: clear Bit_Sets bit Left_visible
08C3: clear Bit_Sets bit Only_Priority_Visible

// 
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Knuckles Settings" key "Always Visible Knuckles"
if 0@ == 1
then 08BD: set Bit_Sets bit Knuckles_Visible
end
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Knuckles Settings" key "Double Knuckles"
if 0@ == 1
then 08BD: set Bit_Sets bit Knuckles_Double
end
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Knuckles Settings" key "Always Visible Double Knuckles"
if 0@ == 1
then 08BD: set Bit_Sets bit Knuckles_Double_Visible
end

//     
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Goggles Settings" key "Goggles On Head"
if 0@ == 1
then 08BD: set Bit_Sets bit Goggles
end

//   
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Priority Settings" key "Priority Back"
if 0@ == 1
then 08BD: set Bit_Sets bit Rifle_Priority
end
if 0@ == 2
then 08BD: set Bit_Sets bit Shotguns_Priority
end
if 0@ == 3
then 08BD: set Bit_Sets bit Sniper_Priority
end
if 0@ == 4
then 08BD: set Bit_Sets bit Parachute_Priority
end

//   
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Priority Settings" key "Priority Left"
if 0@ == 1
then 08BD: set Bit_Sets bit Pistols_Priority
end
if 0@ == 2
then 08BD: set Bit_Sets bit Uzi_Priority
end
if 0@ == 3
then 08BD: set Bit_Sets bit Sawnoff_Priority
end

//    
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Settings" key "Visible on the back"
if 0@ == 1
then 08BD: set Bit_Sets bit Back_visible
end
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Settings" key "Visible on the left"
if 0@ == 1
then 08BD: set Bit_Sets bit Left_visible
end
0AF0: 0@ = read_int_from_ini_file "cleo\The weapon is on the player.ini" section "Settings" key "Only Priority Visible"
if 0@ == 1
then 08BD: set Bit_Sets bit Only_Priority_Visible
end

//    
repeat
wait 0
until player.Defined(0)

//   
model.Load(346)
model.Load(347)
model.Load(348)
model.Load(349)
model.Load(350)
model.Load(351)
model.Load(352)
model.Load(353)
model.Load(372)
model.Load(355)
model.Load(356)
model.Load(357)
model.Load(358)
model.Load(371)
model.Load(331)
model.Load(368)
model.Load(369)
038B: load_requested_models

//    
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #COLT45 bone 41 offset Pistol_X Pistol_Y Pistol_Z rotation 290.0 30.0 0.0 store_to Colt45
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #SILENCED bone 41 offset Pistol_X Pistol_Y Pistol_Z rotation 290.0 30.0 0.0 store_to Silenced
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #DESERT_EAGLE bone 41 offset Pistol_X Pistol_Y Pistol_Z rotation 290.0 30.0 0.0 store_to Deagle
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #SAWNOFF bone 41 offset Pistol_X Pistol_Y Pistol_Z rotation 290.0 30.0 0.0 store_to Sawnoff
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #MICRO_UZI bone 41 offset Pistol_X Pistol_Y Pistol_Z rotation 290.0 30.0 0.0 store_to Micro_uzi
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #TEC9 bone 41 offset Pistol_X Pistol_Y Pistol_Z rotation 290.0 30.0 0.0 store_to Tec9

0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #MP5LNG bone 3 offset Rifle_X Rifle_Y Rifle_Z rotation 180.0 210.0 0.0 store_to Mp5
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #AK47 bone 3 offset Rifle_X Rifle_Y Rifle_Z rotation 180.0 210.0 0.0 store_to ak47
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #M4 bone 3 offset Rifle_X Rifle_Y Rifle_Z rotation 180.0 210.0 0.0 store_to m4
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #CUNTGUN bone 3 offset Rifle_X Rifle_Y Rifle_Z rotation 180.0 210.0 0.0 store_to cuntgun
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #SNIPER bone 3 offset Rifle_X Rifle_Y Rifle_Z rotation 180.0 210.0 0.0 store_to sniper
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #CHROMEGUN bone 3 offset Rifle_X Rifle_Y Rifle_Z rotation 180.0 210.0 0.0 store_to Chromegun
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #SHOTGSPA bone 3 offset Rifle_X Rifle_Y Rifle_Z rotation 180.0 210.0 0.0 store_to Shotgun

0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #GUN_PARA bone 3 offset Rara_X Rara_Y Rara_Z rotation 270.0 90.0 90.0 store_to Parachute

0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #BRASSKNUCKLE bone 24 offset 0 0 0 rotation 0 0 0 store_to Knuckles
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model #BRASSKNUCKLE bone 34 offset 0 0 -0.01 rotation 0 0 0 store_to Knuckles_2

0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model 368 bone 5 offset 0.06 0.105 -0.002 rotation 0 0 -25.0 store_to N_Goggles
0E2E: create_render_object_to_char_bone $PLAYER_ACTOR model 369 bone 5 offset 0.06 0.105 -0.002 rotation 0 0 -25.0 store_to T_Goggles

gosub @Hide_Other //   

//  
model.Destroy(346)
model.Destroy(347)
model.Destroy(348)
model.Destroy(349)
model.Destroy(350)
model.Destroy(351)
model.Destroy(352)
model.Destroy(353)
model.Destroy(372)
model.Destroy(355)
model.Destroy(356)
model.Destroy(357)
model.Destroy(358)
model.Destroy(371)
model.Destroy(331)
model.Destroy(368)
model.Destroy(369)

while true
wait 0
    if
        player.Defined(0)
    then
        gosub @ID_weapon_Pistol //  ID     
        gosub @ID_weapon_Rifle //  ID      
        gosub @ID_render //     1@(Weapon_id_pistol,1i)
        gosub @Hide_Other //   
        
        //    , , ..
        if
            not Pistol == 0 //    
        then
            if
                82D8:   not actor $PLAYER_ACTOR current_weapon == Pistol //     ,   
            then
                if
                    0491:   actor $PLAYER_ACTOR has_weapon Pistol //     ,         .
                then
                    if
                        08B7:   test Bit_Sets bit Left_visible //     
                    then
                        if
                            08B7:   test Bit_Sets bit Only_Priority_Visible //     ,    
                        then
                            if
                                Only_Priority_Pistol == true
                            then
                                0E31: set_render_object_visible 1@(Weapon_id_pistol,1i) 1
                            end
                        else
                            0E31: set_render_object_visible 1@(Weapon_id_pistol,1i) 1
                        end
                    end
                end
            end
        end
        
        //   , , ..
        if
            not Rifle == 0 //    
        then
            if and
                8A0C:   not player $PLAYER_CHAR on_jetpack
                82D8:   not actor $PLAYER_ACTOR current_weapon == Rifle //     ,   
                82D8:   not actor $PLAYER_ACTOR current_weapon == 46 // 
            then
                if
                    0491:   actor $PLAYER_ACTOR has_weapon Rifle //     ,         .
                then
                    if
                        08B7:   test Bit_Sets bit Back_visible //     
                    then
                        if
                            08B7:   test Bit_Sets bit Only_Priority_Visible //     ,    
                        then
                            if
                                Only_Priority_Rifle == true
                            then
                                0E31: set_render_object_visible 1@(Weapon_id_rifle,1i) 1
                            end
                        else
                            0E31: set_render_object_visible 1@(Weapon_id_rifle,1i) 1
                        end
                    end
                end
            end
        end
        
        // 
        if
            08B7:   test Bit_Sets bit Knuckles_Visible //    
        then
            if
                0491:   actor $PLAYER_ACTOR has_weapon 1
            then
                if
                    82D8:   not actor $PLAYER_ACTOR current_weapon == 1
                then
                    0E31: set_render_object_visible Knuckles 1
                end
            end
        end
        if
            08B7:   test Bit_Sets bit Knuckles_Double_Visible //      
        then
            if
                0491:   actor $PLAYER_ACTOR has_weapon 1
            then
                if
                    82D8:   not actor $PLAYER_ACTOR current_weapon == 1
                then
                    0E31: set_render_object_visible Knuckles_2 1
                end
            end
        end
        if
            08B7:   test Bit_Sets bit Knuckles_Double //         
        then
            if
                02D8:   actor $PLAYER_ACTOR current_weapon == 1
            then
                0E31: set_render_object_visible Knuckles_2 1
            end
        end
        
        //    
        if
            08B7:   test Bit_Sets bit Goggles //     
        then
        
            if
                0491:   actor $PLAYER_ACTOR has_weapon 44 //   
            then
                if
                    02D8:   actor $PLAYER_ACTOR current_weapon == 44
                then
                    0A96: 0@ = ped $PLAYER_ACTOR struct
                    0AA6: call_method 0x5E3990 struct 0@ num_params 1 pop 0 368 //    
                end
                if
                    899D:   not night_vision_enabled
                then
                    0E31: set_render_object_visible N_Goggles 1
                end
            end
            
            if
                0491:   actor $PLAYER_ACTOR has_weapon 45 //   
            then
                if
                    02D8:   actor $PLAYER_ACTOR current_weapon == 45
                then
                    0A96: 0@ = ped $PLAYER_ACTOR struct
                    0AA6: call_method 0x5E3990 struct 0@ num_params 1 pop 0 369 //    
                end
                0A8D: 0@ = read_memory 0xC402B9 size 1 virtual_protect 0 // ds:_ZN12CPostEffects17m_bInfraredVisionE, 1 ; CPostEffects::m_bInfraredVision
                if
                    0@ == 0 // 1 -    
                then
                    0E31: set_render_object_visible T_Goggles 1
                end
            end
        end
        
    end
end

:ID_weapon_Pistol
Pistol = 0
Only_Priority_Pistol = false
for 0@ = 22 to 34 step 1 //    ID
    if
        0491:   actor $PLAYER_ACTOR has_weapon 0@
    then
        if or
            0@ == 22 // Pistol
            0@ == 23 // Silenced Pistol
            0@ == 24 // Desert Eagle
            0@ == 26 // Sawn Off Shotgun
            0@ == 28 // Micro Uzi (Mac 10)
            0@ == 32 // Tec9
        then
            041A: Ammo_check = actor $PLAYER_ACTOR weapon 0@ ammo
            if
                Ammo_check == 0 //      ,      true   0491.     
            then
                continue
            end
            
            0085: Pistol = 0@ // (int)
            if
                08B7:   test Bit_Sets bit Pistols_Priority
            then
                if or
                    Pistol == 22 // Pistol
                    Pistol == 23 // Silenced Pistol
                    Pistol == 24 // Desert Eagle
                then
                    gosub @Only_Priority_Visible_Pistol
                    break
                end
            end
            if
                08B7:   test Bit_Sets bit Uzi_Priority
            then
                if or
                    Pistol == 28 // Micro Uzi (Mac 10)
                    Pistol == 32 // Tec9
                then
                    gosub @Only_Priority_Visible_Pistol
                    break
                end
            end
            if
                08B7:   test Bit_Sets bit Sawnoff_Priority
            then
                if
                    Pistol == 26 // Sawn Off Shotgun
                then
                    gosub @Only_Priority_Visible_Pistol
                    break
                end
            end
        end
    end
end
return

:ID_weapon_Rifle
Rifle = 0
Only_Priority_Rifle = false
for 0@ = 22 to 46 step 1 //    ID
    if
        0491:   actor $PLAYER_ACTOR has_weapon 0@
    then
        if or
            0@ == 25 // Shotgun
            0@ == 27 // Combat Shotgun
            0@ == 29 // MP5
            0@ == 30 // AK47
            0@ == 31 // M4
            0@ == 33 // Rifle (Cuntgun)
            0@ == 34 // Sniper Rifle
        then
            041A: Ammo_check = actor $PLAYER_ACTOR weapon 0@ ammo
            if
                Ammo_check == 0 //      ,      true   0491.     
            then
                continue
            end
            
            0085: Rifle = 0@ // (int)
            if
                08B7:   test Bit_Sets bit Shotguns_Priority
            then
                if or
                    Rifle == 25 // Shotgun
                    Rifle == 27 // Combat Shotgun
                then
                    gosub @Only_Priority_Visible_Rifle
                    break
                end
            end
            if
                08B7:   test Bit_Sets bit Rifle_Priority
            then
                if or
                    Rifle == 30 // AK47
                    Rifle == 31 // M4
                then
                    gosub @Only_Priority_Visible_Rifle
                    break
                end
            end
            if
                08B7:   test Bit_Sets bit Sniper_Priority
            then
                if or
                    Rifle == 29 // MP5
                    Rifle == 33 // Rifle (Cuntgun)
                    Rifle == 34 // Sniper Rifle
                then
                    gosub @Only_Priority_Visible_Rifle
                    break
                end
            end
        end
        if
            0@ == 46 // Parachute
        then
            0085: Rifle = 0@ // (int)
            if
                08B7:   test Bit_Sets bit Parachute_Priority
            then
                if
                    Rifle == 46 // Parachute
                then
                    gosub @Only_Priority_Visible_Rifle
                    break
                end
            end
        end
    end
end
return

:Only_Priority_Visible_Pistol
if
    08B7:   test Bit_Sets bit Only_Priority_Visible
then
    Only_Priority_Pistol = true //    Only Priority,           
end
return

:Only_Priority_Visible_Rifle
if
    08B7:   test Bit_Sets bit Only_Priority_Visible
then
    Only_Priority_Rifle = true //    Only Priority,           
end
return

:ID_render
if  pistol == 22 // Pistol
then Weapon_id_pistol = 0 // 1@
end
if  pistol == 23 // Silenced Pistol
then Weapon_id_pistol = 1 // 2@
end
if  pistol == 24 // Desert Eagle
then Weapon_id_pistol = 2 // 3@
end
if  pistol == 26 // Sawn Off Shotgun
then Weapon_id_pistol = 3 // 4@
end
if  pistol == 28 // Micro Uzi (Mac 10)
then Weapon_id_pistol = 4 // 5@
end
if  pistol == 32 // Tec9
then Weapon_id_pistol = 5 // 6@
end

if  Rifle == 25 // Shotgun
then Weapon_id_rifle = 6 // 7@
end
if  Rifle == 27 // Combat Shotgun
then Weapon_id_rifle = 7 // 8@
end
if  Rifle == 29 // MP5
then Weapon_id_rifle = 8 // 9@
end
if  Rifle == 30 // AK47
then Weapon_id_rifle = 9 // 10@
end
if  Rifle == 31 // M4
then Weapon_id_rifle = 10 // 11@
end
if  Rifle == 33 // Rifle (Cuntgun)
then Weapon_id_rifle = 11 // 12@
end
if  Rifle == 34 // Sniper Rifle
then Weapon_id_rifle = 12 // 13@
end
if  Rifle == 46 // Parachute
then Weapon_id_rifle = 13 // 14@
end
return

:Hide_Other
0E31: set_render_object_visible Colt45 0
0E31: set_render_object_visible Silenced 0
0E31: set_render_object_visible Deagle 0
0E31: set_render_object_visible Sawnoff 0
0E31: set_render_object_visible Micro_uzi 0
0E31: set_render_object_visible Tec9 0
0E31: set_render_object_visible ak47 0
0E31: set_render_object_visible m4 0
0E31: set_render_object_visible mp5 0
0E31: set_render_object_visible cuntgun 0
0E31: set_render_object_visible sniper 0
0E31: set_render_object_visible Chromegun 0
0E31: set_render_object_visible Shotgun 0
0E31: set_render_object_visible Parachute 0
0E31: set_render_object_visible Knuckles 0
0E31: set_render_object_visible Knuckles_2 0
0E31: set_render_object_visible N_Goggles 0
0E31: set_render_object_visible T_Goggles 0
return

